const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
    entry:'./src/index.js',
    output:{
        filename: "[name].js",
        path: path.join(__dirname,"./dist"),
        publicPath : 'https://scrum-1323339704.cos.ap-beijing.myqcloud.com/' // 腾讯云存储桶存放静态资源地址
    },
    mode:'production',
    cache:{
        type:'memory',
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:'./public/index.html'
        }),
        new MiniCssExtractPlugin()
    ],
    module:{
        rules:[{
            test:/\.css$/i,
            use:[
                MiniCssExtractPlugin.loader,
                // 'style-loader',
                'css-loader',
            ],
        },{
            test:/\.js$/,
            exclude: /node_modules/,
            use: {
                loader: "babel-loader",
            }
        },{
            test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
            type: 'asset' // 静态资源原样输出
        }]
    }
}

module.exports = config;